﻿using System;
using UnityEngine;
using UnityEngine.Networking;

// Token: 0x0200031B RID: 795
public class ClientPlayer : NetworkBehaviour
{
	// Token: 0x06001437 RID: 5175 RVA: 0x00084E68 File Offset: 0x00083068
	public override void OnStartLocalPlayer()
	{
		ClientPlayer.Instance = this;
		GameController.Instance.RegisterPlayer(this);
		NetworkManagerHUD networkManagerHUD = UnityEngine.Object.FindObjectOfType<NetworkManagerHUD>();
		networkManagerHUD.showGUI = false;
	}

	// Token: 0x06001438 RID: 5176 RVA: 0x00084E93 File Offset: 0x00083093
	public void Update()
	{
		if (base.isLocalPlayer && GameController.playerInstance)
		{
			base.transform.position = GameController.playerInstance.transform.position;
		}
	}

	// Token: 0x06001439 RID: 5177 RVA: 0x00084ECC File Offset: 0x000830CC
	[Command]
	public void CmdSpawnPlayer(string name)
	{
		GameObject gameObject = ObjectManager.LoadPlayer(name);
		NetworkHash128 hash = ObjectManager.GetHash(gameObject.name);
		GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(gameObject, ObjectManager.Instance.spawnPoint, base.transform.rotation);
		NetworkServer.SpawnWithClientAuthority(gameObject2, hash, base.connectionToClient);
		EventManager.SendEvent(new SpawnEvent(gameObject2.GetComponent<EntityBase>()));
	}

	// Token: 0x0600143A RID: 5178 RVA: 0x00084F28 File Offset: 0x00083128
	[Command]
	public void CmdSpawnPlayableGiantess(string name, Vector3 position, float scale, bool useAlternateShaders, bool useAlternateTangents)
	{
		NetworkHash128 hash = ObjectManager.GetHash(name + "_");
		GameObject obj = ObjectManager.Instance.InstantiatePlayableGiantess(name, position, scale, useAlternateShaders, useAlternateTangents);
		NetworkServer.SpawnWithClientAuthority(obj, hash, base.connectionToClient);
	}

	// Token: 0x0600143B RID: 5179 RVA: 0x00084F68 File Offset: 0x00083168
	public GameObject SpawnGiantess(string name, Vector3 position, Quaternion rotation, float scale, int id = -1)
	{
		position = position.ToWorld();
		NetworkHash128 hash = ObjectManager.GetHash(name);
		GameObject gameObject = ObjectManager.Instance.InstantiateGiantess(false, false, name, position, rotation, scale);
		if (gameObject == null)
		{
			return null;
		}
		if (id != -1)
		{
			gameObject.GetComponent<EntityBase>().id = id;
		}
		NetworkServer.SpawnWithClientAuthority(gameObject, hash, base.connectionToClient);
		EventManager.SendEvent(new SpawnEvent(gameObject.GetComponent<EntityBase>()));
		return gameObject;
	}

	// Token: 0x0600143C RID: 5180 RVA: 0x00084FD8 File Offset: 0x000831D8
	[Command]
	public void CmdSpawnGiantess(string name, Vector3 position, Quaternion rotation, float scale, int id)
	{
		this.SpawnGiantess(name, position, rotation, scale, id);
	}

	// Token: 0x0600143D RID: 5181 RVA: 0x00084FE8 File Offset: 0x000831E8
	public GameObject SpawnObject(string name, Vector3 position, Quaternion rotation, float scale, int id = -1)
	{
		position = position.ToWorld();
		NetworkHash128 hash = ObjectManager.GetHash(name);
		GameObject gameObject = ObjectManager.Instance.InstantiateObject(name, position, rotation, scale);
		if (gameObject == null)
		{
			return null;
		}
		if (id != -1)
		{
			gameObject.GetComponent<EntityBase>().id = id;
		}
		NetworkServer.SpawnWithClientAuthority(gameObject, hash, base.connectionToClient);
		EventManager.SendEvent(new SpawnEvent(gameObject.GetComponent<EntityBase>()));
		return gameObject;
	}

	// Token: 0x0600143E RID: 5182 RVA: 0x00085056 File Offset: 0x00083256
	[Command]
	public void CmdSpawnObject(string name, Vector3 position, Quaternion rotation, float scale, int id)
	{
		this.SpawnObject(name, position, rotation, scale, id);
	}

	// Token: 0x0600143F RID: 5183 RVA: 0x00085068 File Offset: 0x00083268
	public GameObject SpawnMicro(bool female, string name, Vector3 position, Quaternion rotation, float scale)
	{
		position = position.ToWorld();
		MicroNPC microNPC;
		NetworkHash128 assetId;
		if (female)
		{
			microNPC = NPCSpawner.Instance.SpawnFemaleNPC(name);
			assetId = ObjectManager.femaleMicroAssetId;
		}
		else
		{
			microNPC = NPCSpawner.Instance.SpawnMaleNPC(name);
			assetId = ObjectManager.maleMicroAssetId;
		}
		if (microNPC == null)
		{
			return null;
		}
		GameObject gameObject = ObjectManager.Instance.InstantiateMicro(microNPC, position, rotation, scale);
		NetworkServer.Spawn(gameObject, assetId);
		gameObject.GetComponent<NetworkIdentity>().localPlayerAuthority = true;
		EventManager.SendEvent(new SpawnEvent(gameObject.GetComponent<EntityBase>()));
		return gameObject;
	}

	// Token: 0x06001440 RID: 5184 RVA: 0x000850F4 File Offset: 0x000832F4
	public GameObject RegisterMicro(GameObject micro, bool female)
	{
		NetworkHash128 assetId = (!female) ? ObjectManager.maleMicroAssetId : ObjectManager.femaleMicroAssetId;
		micro.GetComponent<NetworkIdentity>().localPlayerAuthority = true;
		NetworkServer.SpawnWithClientAuthority(micro, assetId, base.connectionToClient);
		return micro;
	}

	// Token: 0x06001441 RID: 5185 RVA: 0x00085132 File Offset: 0x00083332
	public Player AuthorizePlayer(Player player)
	{
		player.gameObject.GetComponent<NetworkIdentity>().localPlayerAuthority = true;
		NetworkServer.SpawnWithClientAuthority(player.gameObject, player.gameObject.GetComponent<NetworkIdentity>().assetId, base.connectionToClient);
		return player;
	}

	// Token: 0x06001442 RID: 5186 RVA: 0x00085168 File Offset: 0x00083368
	[Command]
	public void CmdSpawnMicro(bool female, Vector3 position, Quaternion rotation, float scale)
	{
		this.SpawnMicro(female, base.name, position, rotation, scale);
	}

	// Token: 0x06001443 RID: 5187 RVA: 0x00002973 File Offset: 0x00000B73
	private void UNetVersion()
	{
	}

	// Token: 0x06001444 RID: 5188 RVA: 0x0008517C File Offset: 0x0008337C
	protected static void InvokeCmdCmdSpawnPlayer(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("Command CmdSpawnPlayer called on client.");
			return;
		}
		((ClientPlayer)obj).CmdSpawnPlayer(reader.ReadString());
	}

	// Token: 0x06001445 RID: 5189 RVA: 0x000851A8 File Offset: 0x000833A8
	protected static void InvokeCmdCmdSpawnPlayableGiantess(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("Command CmdSpawnPlayableGiantess called on client.");
			return;
		}
		((ClientPlayer)obj).CmdSpawnPlayableGiantess(reader.ReadString(), reader.ReadVector3(), reader.ReadSingle(), reader.ReadBoolean(), reader.ReadBoolean());
	}

	// Token: 0x06001446 RID: 5190 RVA: 0x000851F8 File Offset: 0x000833F8
	protected static void InvokeCmdCmdSpawnGiantess(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("Command CmdSpawnGiantess called on client.");
			return;
		}
		((ClientPlayer)obj).CmdSpawnGiantess(reader.ReadString(), reader.ReadVector3(), reader.ReadQuaternion(), reader.ReadSingle(), (int)reader.ReadPackedUInt32());
	}

	// Token: 0x06001447 RID: 5191 RVA: 0x00085248 File Offset: 0x00083448
	protected static void InvokeCmdCmdSpawnObject(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("Command CmdSpawnObject called on client.");
			return;
		}
		((ClientPlayer)obj).CmdSpawnObject(reader.ReadString(), reader.ReadVector3(), reader.ReadQuaternion(), reader.ReadSingle(), (int)reader.ReadPackedUInt32());
	}

	// Token: 0x06001448 RID: 5192 RVA: 0x00085295 File Offset: 0x00083495
	protected static void InvokeCmdCmdSpawnMicro(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("Command CmdSpawnMicro called on client.");
			return;
		}
		((ClientPlayer)obj).CmdSpawnMicro(reader.ReadBoolean(), reader.ReadVector3(), reader.ReadQuaternion(), reader.ReadSingle());
	}

	// Token: 0x06001449 RID: 5193 RVA: 0x000852D4 File Offset: 0x000834D4
	public void CallCmdSpawnPlayer(string name)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("Command function CmdSpawnPlayer called on server.");
			return;
		}
		if (base.isServer)
		{
			this.CmdSpawnPlayer(name);
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)5));
		networkWriter.WritePackedUInt32((uint)ClientPlayer.kCmdCmdSpawnPlayer);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(name);
		base.SendCommandInternal(networkWriter, 0, "CmdSpawnPlayer");
	}

	// Token: 0x0600144A RID: 5194 RVA: 0x00085360 File Offset: 0x00083560
	public void CallCmdSpawnPlayableGiantess(string name, Vector3 position, float scale, bool useAlternateShaders, bool useAlternateTangents)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("Command function CmdSpawnPlayableGiantess called on server.");
			return;
		}
		if (base.isServer)
		{
			this.CmdSpawnPlayableGiantess(name, position, scale, useAlternateShaders, useAlternateTangents);
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)5));
		networkWriter.WritePackedUInt32((uint)ClientPlayer.kCmdCmdSpawnPlayableGiantess);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(name);
		networkWriter.Write(position);
		networkWriter.Write(scale);
		networkWriter.Write(useAlternateShaders);
		networkWriter.Write(useAlternateTangents);
		base.SendCommandInternal(networkWriter, 0, "CmdSpawnPlayableGiantess");
	}

	// Token: 0x0600144B RID: 5195 RVA: 0x00085424 File Offset: 0x00083624
	public void CallCmdSpawnGiantess(string name, Vector3 position, Quaternion rotation, float scale, int id)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("Command function CmdSpawnGiantess called on server.");
			return;
		}
		if (base.isServer)
		{
			this.CmdSpawnGiantess(name, position, rotation, scale, id);
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)5));
		networkWriter.WritePackedUInt32((uint)ClientPlayer.kCmdCmdSpawnGiantess);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(name);
		networkWriter.Write(position);
		networkWriter.Write(rotation);
		networkWriter.Write(scale);
		networkWriter.WritePackedUInt32((uint)id);
		base.SendCommandInternal(networkWriter, 0, "CmdSpawnGiantess");
	}

	// Token: 0x0600144C RID: 5196 RVA: 0x000854E8 File Offset: 0x000836E8
	public void CallCmdSpawnObject(string name, Vector3 position, Quaternion rotation, float scale, int id)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("Command function CmdSpawnObject called on server.");
			return;
		}
		if (base.isServer)
		{
			this.CmdSpawnObject(name, position, rotation, scale, id);
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)5));
		networkWriter.WritePackedUInt32((uint)ClientPlayer.kCmdCmdSpawnObject);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(name);
		networkWriter.Write(position);
		networkWriter.Write(rotation);
		networkWriter.Write(scale);
		networkWriter.WritePackedUInt32((uint)id);
		base.SendCommandInternal(networkWriter, 0, "CmdSpawnObject");
	}

	// Token: 0x0600144D RID: 5197 RVA: 0x000855AC File Offset: 0x000837AC
	public void CallCmdSpawnMicro(bool female, Vector3 position, Quaternion rotation, float scale)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("Command function CmdSpawnMicro called on server.");
			return;
		}
		if (base.isServer)
		{
			this.CmdSpawnMicro(female, position, rotation, scale);
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)5));
		networkWriter.WritePackedUInt32((uint)ClientPlayer.kCmdCmdSpawnMicro);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(female);
		networkWriter.Write(position);
		networkWriter.Write(rotation);
		networkWriter.Write(scale);
		base.SendCommandInternal(networkWriter, 0, "CmdSpawnMicro");
	}

	// Token: 0x0600144E RID: 5198 RVA: 0x00085660 File Offset: 0x00083860
	static ClientPlayer()
	{
		NetworkBehaviour.RegisterCommandDelegate(typeof(ClientPlayer), ClientPlayer.kCmdCmdSpawnPlayer, new NetworkBehaviour.CmdDelegate(ClientPlayer.InvokeCmdCmdSpawnPlayer));
		ClientPlayer.kCmdCmdSpawnPlayableGiantess = 1493609309;
		NetworkBehaviour.RegisterCommandDelegate(typeof(ClientPlayer), ClientPlayer.kCmdCmdSpawnPlayableGiantess, new NetworkBehaviour.CmdDelegate(ClientPlayer.InvokeCmdCmdSpawnPlayableGiantess));
		ClientPlayer.kCmdCmdSpawnGiantess = 1526255023;
		NetworkBehaviour.RegisterCommandDelegate(typeof(ClientPlayer), ClientPlayer.kCmdCmdSpawnGiantess, new NetworkBehaviour.CmdDelegate(ClientPlayer.InvokeCmdCmdSpawnGiantess));
		ClientPlayer.kCmdCmdSpawnObject = 179723022;
		NetworkBehaviour.RegisterCommandDelegate(typeof(ClientPlayer), ClientPlayer.kCmdCmdSpawnObject, new NetworkBehaviour.CmdDelegate(ClientPlayer.InvokeCmdCmdSpawnObject));
		ClientPlayer.kCmdCmdSpawnMicro = 973984021;
		NetworkBehaviour.RegisterCommandDelegate(typeof(ClientPlayer), ClientPlayer.kCmdCmdSpawnMicro, new NetworkBehaviour.CmdDelegate(ClientPlayer.InvokeCmdCmdSpawnMicro));
		NetworkCRC.RegisterBehaviour("ClientPlayer", 0);
	}

	// Token: 0x0600144F RID: 5199 RVA: 0x00085750 File Offset: 0x00083950
	public override bool OnSerialize(NetworkWriter writer, bool forceAll)
	{
		bool result;
		return result;
	}

	// Token: 0x06001450 RID: 5200 RVA: 0x00002973 File Offset: 0x00000B73
	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
	}

	// Token: 0x04001748 RID: 5960
	public static ClientPlayer Instance;

	// Token: 0x04001749 RID: 5961
	private static int kCmdCmdSpawnPlayer = 217338544;

	// Token: 0x0400174A RID: 5962
	private static int kCmdCmdSpawnPlayableGiantess;

	// Token: 0x0400174B RID: 5963
	private static int kCmdCmdSpawnGiantess;

	// Token: 0x0400174C RID: 5964
	private static int kCmdCmdSpawnObject;

	// Token: 0x0400174D RID: 5965
	private static int kCmdCmdSpawnMicro;
}
